//显示公告信息
$(function() {
	var param = getUrlParameters();
	var busType = param.bustype;
	document.title = param.title;
	// 获取传来参数类型
	var year;
	$.ajax({
		type : "POST",
		url : preUrl + "notice/queryNoticeList",
		async : true,
		dataType : "json",
		data : {
			"busType" : busType
		},
		success : function(data) {
			if (data.rspCode == "0002") {
				alert("暂时没有" + param.title + "信息！");
				return;
			}
			if (data.rspCode == "0000") {
				var temp ="";
				var year = "";
				$.each(data.data, function(key, noticeInfo) {
					if (year != noticeInfo.yearIndex) {
						temp = $("#Notice").clone().removeAttr("id").show();
						temp.find(".charge-list").html("");
						$("#NoticeList").append(temp);
					}
					year=noticeInfo.yearIndex;
					
					temp.find(".time").text(year);

					var detailTmp = $("#detailTmp").clone().removeAttr("id");
					detailTmp.find(".lt-lf").html(noticeInfo.deployDate);
					detailTmp.find(".rg-ch").html(noticeInfo.noticeTitle);
					detailTmp.find(".rg-en").html(noticeInfo.noticeContent);
					detailTmp.attr("noticeId", noticeInfo.id);
					temp.find(".charge-list").append(detailTmp);
				});

				addEventDetail();
			}

		},
		error : function(data) {
			alert("服务器繁忙 稍后重试！");
		}
	});

	// 返回用水主页面
	$('.balance-cg-main .previous a').bind('click', function(event) {
		$('.balance-cg-main').hide();
		$('.charge-main').show();
	});
});

function addEventDetail() {
	$('.charge-main .lt-tp').unbind('click');
	$('.charge-main .lt-tp').bind(
			'click',
			function(event) {

				// 显示内容信息 提交请求 根据公告id 查询
				$.ajax({
					type : "POST",
					url : preUrl + "notice/queryNoticeInfo",
					async : true,
					dataType : "json",
					data : {
						noticeId : $(this).attr("noticeId")
					},
					success : function(data) {
						if (data.rspCode == "0000") {
							$(".content-title").html(data.data.noticeTitle);
							$(".content-detail .dt-tm span").text(
									data.data.deployDate);
							$(".content-detail .dt-con").html(
									data.data.noticeContent);

							$('.charge-main').hide();
							$('.balance-cg-main').show();
						} else {
							alert(data.rspMsg || "加载失败，请稍后重试!");
						}

					}
				});
			});
}